package com.jkdz.spyke.rs
{
	import com.jkgh.remedy.core.client.*;
	import flash.utils.ByteArray;
	import flash.net.Socket;

	public class SpykeServerProxy implements SpykeServer
	{
		public var remoteeID:int;
		protected var connection:RemedyClientServerConnection;

		public function SpykeServerProxy(remoteeID:int, connection:RemedyClientServerConnection)
		{
			this.remoteeID = remoteeID;
			this.connection = connection;
		}

		public function createNewRoom(onReturn:Function/*SpykeRoom*/):void
		{
			connection.performCall(remoteeID, function(connection:RemedyClientServerConnection):void {

				RemedyCodec.writeMethodID(connection.getSocket(), 56);

			}, new RemedyFunctionSpecification(onReturn, RemedyMOClassManager.INSTANCE));
		}

		public function connectToRoom(a:String, onReturn:Function/*SpykeRoom*/):void
		{
			connection.performCall(remoteeID, function(connection:RemedyClientServerConnection):void {

				RemedyCodec.writeMethodID(connection.getSocket(), 55);
				RemedyStringClassManager.INSTANCE.writeWithGraph(a, connection, new Vector.<Object>());

			}, new RemedyFunctionSpecification(onReturn, RemedyMOClassManager.INSTANCE));
		}
	}
}
